﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace DaphneTranslatorWPF.ViewModel
{
    public enum enumCreationStrategy { NewAssociation, ExistingAssociation };

    public class NewFileDialogViewModel: INotifyPropertyChanged
    {
        public NewFileDialogViewModel()
        {
            PathViewModel = new PathSelectionViewModel();
            PathViewModel.EnterRelativePath = true;
            ExistingFiles = new List<string>();
        }

        public bool NewAssocChecked
        { get; set; }

        public bool ExistingAssocChecked
        { get; set; }

        public enumCreationStrategy CreateStrategy
        {
            get
            {
                if (NewAssocChecked == true)
                    return enumCreationStrategy.NewAssociation;
                else
                    return enumCreationStrategy.ExistingAssociation;
            }
            set
            {
                if (value == enumCreationStrategy.NewAssociation)
                {
                    NewAssocChecked = true;
                    ExistingAssocChecked = false;
                }
                else
                {
                    NewAssocChecked = true;
                    ExistingAssocChecked = false;
                }

                OnPropertyChanged("NewAssocChecked");
                OnPropertyChanged("ExistingAssocChecked");
            }
        }

        public PathSelectionViewModel PathViewModel
        { get; set; }


        public string FileName
        { get; set; }

        public ICollection<string> ExistingFiles
        { get; set; }


        public void OnPropertyChanged(string sProperty)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(sProperty));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
